#!/bin/bash  
  
# 设置数据库连接信息  
DB_HOST="localhost"  
DB_USER="root"  
DB_PASS="password"  
DB_NAME="test"  
  
# 设置要插入的数据  
DATA_TABLE="my_table"  
DATA_NAME="John Doe"  
DATA_EMAIL="johndoe@example.com"  
  
# 插入数据并检查返回状态  
mysql -h $DB_HOST -u $DB_USER -p$DB_PASS -D $DB_NAME -e "INSERT INTO $DATA_TABLE (name, email) VALUES ('$DATA_NAME', '$DATA_EMAIL')"  
if [ $? -eq 0 ]; then  
  echo "Data inserted successfully."  
else  
  echo "Data insertion failed."  
fi

# 删除插入的数据  
mysql -h $DB_HOST -u $DB_USER -p$DB_PASS -D $DB_NAME -e "DELETE FROM $DATA_TABLE WHERE name='$DATA_NAME' AND email='$DATA_EMAIL'"  
if [ $? -eq 0 ]; then  
  echo "Data deleted successfully."  
else  
  echo "Data deletion failed."  
fi